package com.dragon.loan.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Map;

import org.apache.log4j.Logger;

import com.dragon.loan.StrategyInterface;

public class StrategyResponse implements Serializable,StrategyInterface {
	private static final long serialVersionUID = 1502349935953746934L;
	private boolean ruleGeneralResult;
	private String ruleGeneralName;
	// 消金
	private Double xiaoJScore;
	// 小贷
	private Double xiaoDScore;
	
	// 云保贷评分
	private BigDecimal appscYbdXdScore;

	public static StrategyResponse getStrategyResponseByMap(Map<String, Object> map) {
		StrategyResponse strategyResponse = new StrategyResponse();
	/*	strategyResponse.setXiaoDScore((Double) map.get("appsc_xd_level"));
		strategyResponse.setXiaoJScore((Double) map.get("appsc_xj_level"));
		System.out.println("==================>>>getStrategyResponseByMap===appsc_xd_score" + map.get("appsc_xd_score"));
		strategyResponse.setAppscYbdXdScore(getBigDecimalValue(map.get("appsc_xd_score")));
		strategyResponse.setRuleGeneralResult(!"拒绝".equals((String) map.get("decision_type")));*/
	/*	decision_result=拒绝
		decision_version_code=YBD_2.0.0_20180316
*/
		strategyResponse.setXiaoDScore((Double) map.get("appsc_xd_level"));
		strategyResponse.setXiaoJScore((Double) map.get("appsc_xd_level"));
		strategyResponse.setAppscYbdXdScore(getBigDecimalValue(map.get("appsc_xd_score")));
		strategyResponse.setRuleGeneralResult(!(map.get("decision_result") == null || "拒绝".equals((String) map.get("decision_result"))));
		return strategyResponse;
	}
	
	public static StrategyResponse getStrategyYFDResponseByMap(Map<String, Object> map) {
		StrategyResponse strategyResponse = new StrategyResponse();
		strategyResponse.setXiaoDScore((Double) map.get("appsc_xd_level"));
		System.out.println("==================>>>getStrategyYFDResponseByMap===appsc_xd_score" + map.get("appsc_xd_score"));
		strategyResponse.setXiaoJScore((Double) map.get("appsc_xj_level"));
		strategyResponse.setAppscYbdXdScore(getBigDecimalValue(map.get("appsc_xd_score")));
		strategyResponse.setRuleGeneralResult(!"拒绝".equals((String) map.get("decision_type")));
		return strategyResponse;
	}


	
	public BigDecimal getAppscYbdXdScore() {
		return appscYbdXdScore;
	}

	public void setAppscYbdXdScore(BigDecimal appscYbdXdScore) {
		this.appscYbdXdScore = appscYbdXdScore;
	}

	public boolean isRuleGeneralResult() {
		return ruleGeneralResult;
	}

	public void setRuleGeneralResult(boolean ruleGeneralResult) {
		this.ruleGeneralResult = ruleGeneralResult;
	}

	public String getRuleGeneralName() {
		return ruleGeneralName;
	}

	public void setRuleGeneralName(String ruleGeneralName) {
		this.ruleGeneralName = ruleGeneralName;
	}

	public Double getXiaoJScore() {
		return xiaoJScore;
	}

	public void setXiaoJScore(Double xiaoJScore) {
		this.xiaoJScore = xiaoJScore;
	}

	public Double getXiaoDScore() {
		return xiaoDScore;
	}

	public void setXiaoDScore(Double xiaoDScore) {
		this.xiaoDScore = xiaoDScore;
	}

	   private static BigDecimal getBigDecimalValue(Object obj){
	    	if(obj != null){
	    		try {
	    			BigDecimal bigDecimal = new BigDecimal((double)obj);
					return bigDecimal;
				} catch (Exception e) {
					e.printStackTrace();
					return null;
				}
	    	}
	    	return null;
	    }

	@Override
	public String toString() {
		return "StrategyResponse [ruleGeneralResult=" + ruleGeneralResult + ", ruleGeneralName=" + ruleGeneralName
				+ ", xiaoJScore=" + xiaoJScore + ", xiaoDScore=" + xiaoDScore + ", appscYbdXdScore=" + appscYbdXdScore
				+ "]";
	}

	
	   
	   
}
